Effects of the `extern` keyword on C functions
Posted
by Elazar Leibovich
on Stack Overflow
See other posts from Stack Overflow
or by Elazar Leibovich
Published on 2009-05-13T07:51:53Z
Indexed on
2010/06/15
1:22 UTC
Read the original article
Hit count: 324
In C I did not notice any effect of the extern keyword used before function declaration.
At first I thougth that when defining extern int f();
in a single file forces you to implement it outside of the files scope, however I found out that both
extern int f();
int f() {return 0;}
And
extern int f() {return 0;}
Compiles just fine, with no warnings from gcc. I used gcc -Wall -ansi
, he wouldn't even accept //
comments.
Are there any effects for using extern
before function definitions? Or is it just an optional keyword with no side effects for functions.
In the latter case I don't understand why did the standard designers chose to litter the grammar with superfluous keywords.
EDIT: to clarify, I know there's usage for extern in variables, but I'm only asking about extern in functions.
© Stack Overflow or respective owner